package com.example.myandroidtest.ui.retrofit;

import java.sql.SQLOutput;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.ObservableSource;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.internal.operators.observable.ObservableFromArray;
import io.reactivex.internal.operators.observable.ObservableMap;

public class RxJavaTest {
    //观察者   Observer
    //消费者  consumer
    //被观察者  Observable
    //订阅 subscribe
    //操作符分类创建 转换

    public void test() {
        //ObservableFromArray.
        //ObservableMap

        Observable<String> just = Observable.just("123", "456");
        Observable<String> map = just.map(new Function<String, String>() {
            @Override
            public String apply(String s) throws Exception {
                System.out.println("map+" + s);
                return "map+" + s;
            }
        });

        map.subscribe(new Observer<String>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(String s) {
                System.out.println("onNext" + s);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });

//        just.map(s -> System.out.println(""+"map+" + s));


//        Observable.create(emitter -> {
//            emitter.onNext("123");
//            emitter.onNext("456");
//        }).subscribe(new Observer<Object>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//
//            }
//
//            @Override
//            public void onNext(Object o) {
//                System.out.println("Observable.create" + o);
//            }
//
//            @Override
//            public void onError(Throwable e) {
//
//            }
//
//            @Override
//            public void onComplete() {
//
//            }
//        });
//
//        Observable.fromArray("123", "456").subscribe(s -> System.out.println("Observable" +
//                ".fromArray" + s));


//        ObservableSource observableSource;
//        ObservableMap map;


    }
}
